package com.zhj.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhj.product.converter.CarouselConverter;
import com.zhj.product.entity.dto.CarouselDTO;
import com.zhj.product.entity.pojo.Carousel;
import com.zhj.product.mapper.CarouselMapper;
import com.zhj.product.service.CarouselService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * 轮播图服务
 */
@Service
@AllArgsConstructor
public class CarouselServiceImpl implements CarouselService {

    private final CarouselMapper carouselMapper;

    @Override
    public List<Carousel> findAll(Integer isShow) {
        LambdaQueryWrapper<Carousel> queryWrapper = new QueryWrapper<Carousel>()
                .lambda()
                .eq(Carousel::getIsShow, isShow)
                .orderByDesc(Collections.singletonList(Carousel::getCreateTime));
        return this.carouselMapper.selectList(queryWrapper);
    }
}

